package effectiveJava.throwble;

import java.util.ArrayList;
import java.util.List;

/*TODO 一次抛出多个异常*/
public class MyException extends Exception {

    private List<Throwable> causes = new ArrayList<>();

    public MyException(List<Throwable> _list) {
        causes.addAll(_list);
    }

    public List<Throwable> getCauses() {
        return causes;
    }

    public static void main(String[] args) throws MyException {
        List<Throwable> causes = new ArrayList<>();
        try {
            //doSomeThing
        } catch (Exception e) {
            causes.add(e);
        }
        try {
            //doSomeThing
        } catch (Exception e) {
            causes.add(e);
        }
        if (causes.size() > 0) {
            throw new MyException(causes);
        }
    }
}
